package com.sw.controller;

import com.sw.dto.UserLoginDTO;
import com.sw.result.R;
import com.sw.service.IndexService;
import com.sw.vo.LoginVO;
import com.sw.vo.ProfileVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 基础设置控制类
 *
 * @project: com.sw.controller
 * @author: Szh
 * @date: 2023/9/19 19:02
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/index")
public class IndexController {
    private final IndexService indexService;

    @PostMapping("/login")
    public R<?> login(@RequestBody UserLoginDTO userLoginDTO){
        log.info("接收到数据:{}",userLoginDTO);
        LoginVO userLoginVO = indexService.login(userLoginDTO);
        return R.success(userLoginVO);
    }

    @PostMapping("/profile")
    public R<ProfileVO> profile() {
        ProfileVO profileVO = indexService.profile();
        return R.success(profileVO);
    }
}
